import request from '@/utils/request'

export const reqFoodList = (PageParams) => request({
  url: '/food/foodlist',
  method: 'post',
  data: PageParams
})

// 修改  或者  添加

export const reqAddOrUpdateFood = (food) => {
  // 如果有id，那么就是修改food
  if (food.id) {
    return request({ url: '/food/update', method: 'post', data: food })
  } else {
    // 没有id，那就是新增food
    return request({ url: '/food/save', method: 'post', data: food })
  }
}

// 删除food
export const reqRemoveFood = (id) => request({
  url: `/food/remove/${id}`,
  method: 'get'
})
